package com.zhanglijie.theory.ArrayListDemo.cponwriteArraylist;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author zhanglijie
 * @version 1.0
 * @since 1.1.0 2022/7/25 0025 22:30
 */
public class ReadThread extends Thread {
    private CopyOnWriteArrayList<Integer> cpList;
    public ReadThread(CopyOnWriteArrayList<Integer> cp){
        this.cpList = cp;
    }
    @Override
    public void run() {
        for(int i=0;true;i++){
            cpList.add(i);//add 方法会加锁
        }
    }
}
